package com.goktech.sportsmall.controller;

import com.goktech.sportsmall.bean.CommodityBean;
import com.goktech.sportsmall.service.CommodityService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import java.util.List;
import java.util.Map;

@RestController
@RequestMapping("/comm")
public class VueCommController {


    @Autowired(required = false)
    private CommodityService commodityService;

    @RequestMapping(value = "addCommodity",method = RequestMethod.POST)
    public String addCommodity(CommodityBean commodityBean) {
        return commodityService.addCommodity(commodityBean);
    }


    @RequestMapping(value = "selectList",method = RequestMethod.GET)
    public List<CommodityBean> selectList(CommodityBean commodityBean) {
        return commodityService.selectList(commodityBean);
    }

    // 分页查询
    @RequestMapping(value = "limitSelect",method = RequestMethod.GET)
    public Map<String, Object> limitSelect(int page, int size) {
        return commodityService.limitSelect(page, size);
    }

    // 删除信息
    @RequestMapping(value = "deleteCommodity",method = RequestMethod.DELETE)
    public String deleteCommodity(String no) {
        return commodityService.deleteCommodity(no);
    }

    // 更新信息
    @RequestMapping(value = "updateCommodity",method = RequestMethod.PUT)
    public String updateCommodity(CommodityBean commodityBean) {
        return commodityService.updateCommodity(commodityBean);
    }

    @RequestMapping(value = "queryLimitSelect",method = RequestMethod.GET)
    public Map<String, Object> queryLimitSelect(String c_name, String c_sort, String c_detail, int page, int size) {
        return commodityService.queryLimitSelect(c_name, c_sort, c_detail, page, size);
    }

}
